package com.mr.shiro.mapper;

import com.mr.shiro.webapps.system.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * Class: UserMapper
 * User (作者):MRui
 * TODO (描述)：user
 * Date 2019-01-13 17:49
 */
public interface UserMapper {

    @Insert(" insert into user (" +
            " uid," +
            " user_name," +
            " pass_word)" +
            " values(" +
            " #{uid,jdbcType=INTEGER}," +
            " #{userName,jdbcType=VARCHAR}," +
            " #{passWord,jdbcType=VARCHAR}"
    )
    int saveUser(User user);

    @Select(" select u.*,r.*.p.* " +
            " from user u" +
            " inner join user_role ur on ur.uid = u.uid" +
            " inner join r on r.rid = ur.rid" +
            " inner permission role pr on pr.rid = r.rid" +
            " inner permission p on pr.pid = p.pid" +
            " where u.user_name = #{userName,jdbcType=VARCHAR}")
    User getUser(String userName);

}
